﻿@page
@model Chino.IdentityServer.Pages.Dashboard.Client.RedirectUrisModel
@inject IStringLocalizer<Chino.IdentityServer.Pages.Dashboard.ClientsModel> ClientL
@inject IStringLocalizer<Chino.IdentityServer.Pages.Dashboard.Client.RedirectUrisModel> L
@{
    Layout = "_DashboardLayout";
    ViewData["pageName"] = "clients";

    var thisUrl = string.IsNullOrEmpty(Request.Path) ? "~/" : $"~{Request.Path.Value}";
}

<div class="mt-3 container">

    @*面包屑*@
    <div class="card-body mb-3 py-0 px-0">
        <nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a asp-page="/Dashboard/Clients">@ClientL["breadcrumb_Clients"]</a></li>
                <li class="breadcrumb-item">@Model.ClientEntity.ClientName</li>
                <li class="breadcrumb-item active" aria-current="page">@L["breadcrumb_redirectUris"]</li>
            </ol>
        </nav>
    </div>

    <partial name="ValidationSummary" />

    @*卡片：添加跨域*@
    <div class="card mb-3">
        <div class="card-header">
            <h6 class="h6">@L["card_header_addredirectUri"]</h6>
        </div>
        <div class="card-body">
            <form method="post">
                @*隐藏内容*@
                <input asp-for="ReturnUrl" hidden />
                <input asp-for="Id" hidden />

                <div class="mb-3 row">
                    <label class="form-label col-sm-3 col-form-label">
                        @L["label_redirectUri"]
                    </label>
                    <div class="col-sm-9">
                        <input name="redirectUri" id="newRedirectUri" class="form-control" autocomplete="off" />
                    </div>
                </div>

                <button class="btn btn-primary" type="submit">@L["btn_add"]</button>
            </form>
        </div>
    </div>

    @*卡片：已有跨域来源列表（就不分页了吧）*@
    <div class="card mb-3">
        <div class="card-header">
            <h6 class="h6">@L["card_header_redirectUris"]</h6>
        </div>
        <div class="card-body">
            <ul class="list-group-flush">
                @foreach (var redirectUri in Model.ClientEntity.RedirectUris)
                {
                    <li class="list-group-item">
                        <a asp-page="RedirectUris"
                           asp-page-handler="DeletItem"
                           asp-route-Id="@Model.Id"
                           asp-route-ReturnUrl="@Model.ReturnUrl"
                           asp-route-redirectUriId="@redirectUri.Id" class="btn btn-danger btn-sm py-1 px-3 mr-3"><span class="oi oi-x"></span></a>
                        @redirectUri.RedirectUri
                    </li>
                }
            </ul>
        </div>
    </div>
</div>